ibarshift()

ibarshift() | Previous Top Next

The function returns bar shift with the open time specified.
int ibarshift (int timeframe, // timeframe
long datetimeserial, // time
int limit, // bars back
bool exact=0 // mode
);
Parameters
timeframe
[in] Timeframe. It can be any of PERIOD_ enumeration values.
datetimeserial
[in] Value to find (bar's open unix time).
limit
[in] Limit the search to the specified number of bars back
exact=0
[in] Return mode when bar not found (0 : ibarshift returns nearest, 1 : ibarshift returns -1).
Returned value
Bar shift with the open time specified. If the bar having the specified open time is missing, the function will return -1 or the nearest bar shift depending on the exact.
Example:

long some_time=timeb[5]; int shift=ibarshift(PERIOD_D1,some_time); Printf("shift of bar with open time ",some_time," is ",shift);